package com.fzkj.shejimoshi.strategy3;

/**
 * @DESCRIPTION: TODO 策略工厂，完成对不同策略的选择
 * @AUTHOR: AnotherOne
 * @DATE: 2021/8/13 16:57
 */
public class LoginStrategyFactory {
    private LoginStrategy strategy;
    public void choiceStrategy(LoginStrategy strategy){
        this.strategy = strategy;
    }
    public void choiceStrategy(Class<? extends LoginStrategy> clazz){
        try {
            this.strategy = clazz.newInstance();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    public LoginStrategy getStrategy(){
        return this.strategy;
    }

    public void login(String username){
        this.strategy.login(username);
    }

}
